/**********************************************************************
 * Project : WoWGuildRoster (http://www.codeplex.com/WowGuildRoster/)
 * Module  : DotNetWarcraft.WoWGuildRoster.Business.CharEntryUser
 **********************************************************************
 * 
 * 
 * 
 **********************************************************************
 * License : All code is subject to licensing terms per the Microsoft
 *   Permissive License (Ms-PL) v1.1. For full license information,
 *   refer to the packaged license.txt file.
 **********************************************************************
 * Revision History:
 * -----------------
 * 2007-09-18 -- Cliff Simpkins: Initial Version
 **********************************************************************
 */
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

using DotNetWarcraft.Common;

namespace DotNetWarcraft.WoWGuildRoster.Business {
  /// <summary>
  /// Roster mapping to a DNN module.
  /// </summary>
  public class CharEntryUser {
    #region Protected Members
    protected int _char_id;
    protected int _portal_id;
    protected int _user_id;
    #endregion
    #region Public Properties
    public int UserID {
      get {
        return _user_id;
      }
      set {
        _user_id = value;
      }
    }
    public int PortalID {
      get {
        return _portal_id;
      }
      set {
        _portal_id = value;
      }
    }

    public int CharID {
      get {
        return _char_id;
      }
      set {
        _char_id = value;
      }
    }
    #endregion
    #region Public Interpreted Properties
    public GuildEntry CharEntry {
      get {
        if (this.CharID > 0) {
          return DnnGuildRosterController.GetCharEntry(this.CharID);
        } else return new GuildEntry();
      }
    }
    public DotNetNuke.Entities.Users.UserInfo DnnUser {
      get {
        if (this.UserID >= 0 && this.PortalID >= 0) {
          return DotNetNuke.Entities.Users.UserController.GetUser(this.PortalID, this.UserID, true);
        } else
          return new DotNetNuke.Entities.Users.UserInfo();
      }
    }
    #endregion

    #region Constructors
		public CharEntryUser() : base() {
      this.CharID = -1;
      this.PortalID = -1;
      this.UserID = -1;
    }
    public CharEntryUser(int charID, int portalID, int userID) : this() {
      this.CharID = charID;
      this.PortalID = portalID;
      this.UserID = userID;
    }

    public CharEntryUser(DataRow rosterModSrc) : this() {
      this.CharID = SqlDataUtils.RetrieveDbInt(rosterModSrc["char_id"]);
      this.PortalID = SqlDataUtils.RetrieveDbInt(rosterModSrc["portal_id"]);
      this.UserID = SqlDataUtils.RetrieveDbInt(rosterModSrc["user_id"]);
    }

    #endregion
  }
}
